﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BSCMFF.Core.DataAccessLayer;

namespace BSCMFF.Web.Pages.working
{
    public partial class persokanKPI_edit : BSCMFF.Core.MultiLanguagePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["loggedUserID"] == null)
            {
                return;
            }
            if (!IsPostBack)
            {
                LoadInferiorEmployees((int)Session["loggedUserID"]);
            }
            if (RadComboBoxEmployee.SelectedValue != "")
            {
                PanelEmployeePKPIs.Visible = true;
                //LoadPKPIs(Int32.Parse(RadComboBoxEmployee.SelectedValue));
            }
        }

        private void LoadInferiorEmployees(int loggedUserID)
        {
            BSCEntities context = new BSCEntities();

            List<User> users = (from user in context.Users
                                where user.Manager_FK == loggedUserID
                                select user).ToList();

            RadComboBoxEmployee.DataSource = users;
            RadComboBoxEmployee.DataBind();
        }

        private void LoadPKPIs(int userID)
        {
            BSCEntities context = new BSCEntities();
            List<Personal_KPI> pkpis = (from pks in context.Personal_KPI.Include("KPI")
                                        where pks.User_FK == userID
                                        select pks).ToList();

            RadGridPersonalKPIs.DataSource = pkpis;
            RadGridPersonalKPIs.DataBind();
        }
    }
}